{extend name="admininfo/admininfo" /}
{block name='main'}
<form class="form-horizontal" action="{:url('admin/Admininfo/add')}" method='post' enctype="multipart/form-data">
    <div class="modal-body">
        <h2>管理员添加</h2>
        <table class="table table-bordered" >
            <tr>
                <td>用户名</td>
                <td><input type="text" name='name' value=""></td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input type="password"  name='pass' value="" placeholder='请输入密码' maxlength='18' minlength='6' id="pass"></td>
            </tr>
            <tr>
                <td>确认密码</td>
                <td>
                    <input type="password"  name='repass' value="">
                </td>
            </tr>
            <tr>
                <td>角色分配</td>
                <td>
                    {foreach $list as $v}
                        <input type="checkbox" value="{$v['id']}" name='arr[]'>{$v['role']}
                    {/foreach}
                </td>
            </tr>
            <tr>

                <td colspan="2" style="text-align:center">
                    <button class="btn btn-primary adds" type='submit'>
                        确认添加
                    </button>               
                    
                </td>
            </tr>
        </form>
        
        </table>
    </div>


    <script>
        $(function(){
           $("#pass").blur(function(){
               var pass = $('#pass').val();
               if (pass.match(/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,18}$/) === null) {
                    var HTM = "<b style='color:red'>密码必须由6-18位字母数字共同组成</b>"
                    $('#pass').after(HTM)
               }

           });

           $("#pass").focus(function(){ 
               $('#pass').next().remove()
           }); 

        })
    </script>


{/block}